package xyz.zhzby.cyzx.cms.convert;

import io.swagger.annotations.ApiModel;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import xyz.zhzby.cyzx.cms.dto.request.ArticleAddRequest;
import xyz.zhzby.cyzx.cms.dto.response.ArticleResponse;
import xyz.zhzby.cyzx.cms.entity.Article;

import java.util.List;

/**
 * @author zby
 * @date 2021/12/10
 */
@ApiModel("文章相关转换器")
@Mapper(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE, nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface ArticleConvert {

    ArticleConvert INSTANCE = Mappers.getMapper(ArticleConvert.class);

    Article REQUEST_ARTICLE(ArticleAddRequest articleAddRequest);

    @Mappings({
        @Mapping(target = "publishTime", source = "updateTime")
    })
    ArticleResponse ARTICLE_RESPONSE(Article article);

    List<ArticleResponse> ARTICLE_RESPONSE_LIST(List<Article> articles);
}
